<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

$cakeDescription = __d('TBWA', 'TBWA');
?>
<!DOCTYPE html>
<html>
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		<?php echo $cakeDescription ?>:
		<?php echo $title_for_layout; ?>
	</title>
	<?php
		echo $this->Html->meta('icon');

		echo $this->Html->css('cake.generic');
		echo $this->Html->css('styleguide');
		echo $this->Html->script('jquery-lib');
		echo $this->Html->script('functions');

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');
		
		$userId = $this->Session->read('Auth.User.id');
		$userName = $this->Session->read('Auth.User.username');
		$userRole = $this->Session->read('Auth.User.role');
	?>
</head>
<body>
	<div id="container">
		<div id="header">
			<h1 class="logo">
            <?php echo $this->Html->link(
					$this->Html->image('logo.png', array('alt' => $cakeDescription, 'border' => '0', 'width' => '50', 'align' => 'absmiddle')),
					array('controller' => 'timesheets', 'action' => 'index'),
					array('target' => '', 'escape' => false)
				);
			echo $this->Html->link($cakeDescription, array('controller' => 'timesheets', 'action' => 'index')); ?></h1>
            
			<?php if(!empty($userId)): ?>
            <ul class="navigation">
                <li <?php if($this->params['controller'] == 'timesheets'): echo 'class="active"'; endif; ?>><?php echo $this->Html->link('Timesheets',array('controller' => 'timesheets', 'action' => 'index')); ?></li>
                
                <?php if($userRole == 'superadmin' || $userRole == 'managers'): //superadmin and team leads?>
                	<li <?php if($this->params['controller'] == 'clients'): echo 'class="active"'; endif; ?>><?php echo $this->Html->link('Clients',array('controller' => 'clients', 'action' => 'index')); ?></li>
                 <?php endif; ?>
                 
                 
                 
				<?php if($userRole == 'superadmin'): //superadmin only ?>
                    <li <?php if($this->params['controller'] == 'departments'): echo 'class="active"'; endif; ?>><?php echo $this->Html->link('Departments',array('controller' => 'departments', 'action' => 'index')); ?></li>
                <?php endif; ?>
                
                <?php if($userRole == 'superadmin' || $userRole == 'admin'): //superadmin and HR ?>
    				<li <?php if($this->params['controller'] == 'users' || $this->params['controller'] == 'holidays'): echo 'class="active"'; endif; ?>><?php echo $this->Html->link('Admin',array('controller' => 'users', 'action' => 'index')); ?></li>
                <?php endif; ?>
                
            </ul>
            
            
             <ul class="navigation" style="float:right;">
             	<li><a href="javascript:void(0);"><?php echo $userName; ?></a></li>
                <li><?php echo $this->Html->link('Logout',array('controller' => 'users', 'action' => 'logout')); ?></li>
            </ul>
            <?php endif; ?>
            
            
	<div id="content">

			<?php echo $this->Session->flash(); ?>

			<?php echo $this->fetch('content'); ?>
		</div>
		<div id="footer">
			<?php /*echo $this->Html->link(
					$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
					'http://www.cakephp.org/',
					array('target' => '_blank', 'escape' => false)
				);*/
			?>
		</div>
	</div>
	<?php //echo $this->element('sql_dump'); ?>
</body>
</html>
